//
//  MusicControl.m
//  iPhoneControlApplication
//
//  Created by Elliot Chapple on 11/04/2009.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "MusicControl.h"


@implementation MusicControl
	
//synth objects
@synthesize	playButton;
@synthesize	pauseButton;
@synthesize	nextTrack; 
@synthesize	previousTrack;
@synthesize shuffle;
@synthesize repeat;
@synthesize mute;
@synthesize eject;
@synthesize volumeSlider;
@synthesize trackName;
@synthesize	trackAlbum;
@synthesize trackArtist;
@synthesize trackArtwork;


//Methods

-(IBAction)volumeSliderChange:(id)sender
{
	UISlider *slider = (UISlider *)sender;
	int volumeChange = (int)(slider.value);
	
	NSString *newVolume = [[NSString alloc] initWithFormat:@"%d", volumeChange];
	NSString *alertMessage = [[NSString alloc] initWithFormat:@"The new Volume is %@",newVolume];
	
	UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Volume Altered" message:alertMessage delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil];
	[alert show];
	[alert release];
}

-(IBAction)buttonPress:(id)sender;
{
	
	NSString *title = [sender titleForState:UIControlStateNormal];
	NSString *newText = [[NSString alloc] initWithFormat:@"The %@ button has been selected", title];
	UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Button Selected" message:newText delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil];
	[alert show];
	[alert release];
	[newText release];
}


-(IBAction)nowPlayingInformation;
{	NSString *newText = [[NSString alloc] initWithFormat:@"The Play Button has been selected"];
	NSString *fullText = [[NSString alloc] initWithFormat:@"%@ \n Now Playing %@ by %@", newText, trackName.text, trackArtist.text];
	UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Button Selected" message:fullText delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil];
	[alert show];
	[alert release];
	[newText release];
	
}







//Apple standard code as in others
/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/

/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/

/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
    // Release anything that's not essential, such as cached data
}


- (void)dealloc {
    [super dealloc];
}


@end
